package cn.jbolt.meinvtu.photo;

import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;

import cn.jbolt.meinvtu.common.model.Album;
import cn.jbolt.meinvtu.common.model.Meinv;
import cn.jbolt.meinvtu.common.model.Photo;

public class PhotoController extends Controller {
	@Inject
	private PhotoService service;
	public void index(){
		Integer albumId=getInt(0);
		if(albumId!=null&&albumId>0){
			set("dataList", service.getByAlbum(albumId));
			Album album=Album.dao.findById(albumId);
			if(album!=null){
				Meinv meinv=Meinv.dao.findById(album.getMeinvId());
				if(meinv!=null){
					set("meinvName", meinv.getName());
				}
				set("albumName",album.getName() );
			}
		}
		render("index.html");
	}
	
	public void detail(){
		Photo photo=Photo.dao.findById(getInt(0));
		set("photo", photo);
		set("prevId", service.getPrevId(photo.getAlbumId(),photo.getId()));
		set("nextId", service.getNextId(photo.getAlbumId(),photo.getId()));
		render("detail.html");
	}
}
